package jt.classic.app.util;

import org.limp.mine.DateTrimmer;


public class DateUtilMy {
    public static float getMinutes(String date) {
        float result;

        String hh = date.substring(0, 2);
        String mm = date.substring(2, 4);
        result = (Integer.parseInt(hh) * 60) + Integer.parseInt(mm);

        return result;
    }

    /**
     * 获得时间分钟差值
     * @param date
     * @return
     */
    public static float getMinutesCha(String date, String date2) {
        float result;

        result = DateUtilMy.getMinutes(date2) - DateUtilMy.getMinutes(date);

        return result;
    }

    /**
     *
     * 获得日期
     * 输入 20090102030400
     * 输出 2009-1-2
     * @param date
     * @return
     */
    public static String getDate(String datetime) {
        String result = "";

        if (!datetime.equals("")) {
            String date = datetime.substring(0, 8);
            result = DateTrimmer.getYMD_LBL(date);
        }

        return result;
    }

    /**
     *
     * 获得 时间
     * 输入 20090102030400
     * 输出 03:04
     * @param date
     * @return
     */
    public static String getH_M(String datetime) {
        String result = "";

        if (!datetime.equals("")) {
            String date = datetime.substring(8, 12);
            result = date.substring(0, 2) + ":" + date.substring(2, 4);
        }

        return result;
    }

    /**
     *
     * 获得 时间
     * 输入 20090102030400
     * 输出 03:04:00
     * @param date
     * @return
     */
    public static String getH_M_S(String datetime) {
        String result = "";

        if (!datetime.equals("")) {
            String date = datetime.substring(8, 14);
            result = date.substring(0, 2) + ":" + date.substring(2, 4) + ":" +
                date.substring(4, 6);
        }

        return result;
    }

    /**
     *
     * 获得 时间
     * 输入 20090102030400
     * 输出 2009-1-2 03:04
     * @param date
     * @return
     */
    public static String getNYR_H_M_S(String datetime) {
        String result = "";

        if ((datetime != null) && (datetime.length() == 14)) {
            result = DateUtilMy.getDate(datetime) + " " +
                DateUtilMy.getH_M_S(datetime);
        }

        return result;
    }
}
